//等待线程——join()
public class Test_2_5 {
    public static void main(String[] args) throws InterruptedException {
        Runnable target = () -> {
            for (int i = 0; i < 10; i++) {
                try {
                    System.out.println(Thread.currentThread().getName() + " :我还在工作" + i);
                    Thread.sleep(1000);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            System.out.println(Thread.currentThread().getName()+"线程结束");
        };

        Thread t1 = new Thread(target, "李四");
        Thread t2 = new Thread(target, "王五");
        System.out.println("先让李四开始工作");
        t1.start();
        t1.join();
        System.out.println("李四工作结束，让王五开始工作");
        t2.start();
        t2.join();
        System.out.println("王五工作结束");
        
    }
}
